<?php
class DefaultUserByRoleGetter  {

	// ----------------------------------------
	// ----- Props
	// ----------------------------------------
	/**
	 * @type Array
	 */
	public $userByRoleOverrideMap = array ();

	// ----------------------------------------

	public function DefaultUserByRoleGetter() {
		// Empty
	}

	// ----------------------------------------
	// ----- Props Methods
	// ----------------------------------------

	/**
	 *	@return Array
	 */
	public function & getUserByRoleOverrideMap() {
		return $this->userByRoleOverrideMap;
	}

	/**
	 * @param array of userByRoleOverrideMap
	 * @return void
	 */
	public function setUserByRoleOverrideMap(& $userByRoleOverrideMap) {
		$this->userByRoleOverrideMap = & $userByRoleOverrideMap;
	}

	// ----------------------------------------
	// ----- IUserByRoleGetter Methods
	// ----------------------------------------

	/**
	 * @param session
	 * @return void
	 */
	public function init(& $session) {
		$userByRoleOverrideMap = array ();
		/**
		 * var key id del rol
		 * var value el usuario que tiene el rol key
		 */
		foreach ($this->userByRoleOverrideMap as $key => & $user) {
			$role = & $session->get('MRole', $key);
			$userByRoleOverrideMap[$role->epGetObjectId()] = & $user;
		}

		$this->userByRoleOverrideMap = & $userByRoleOverrideMap;
	}

	/**
	 * @param Session
	 * @param MRol
	 * @return MUser
	 */
	public function & getUserByRole($session, $role) {
		if (isset ($this->userByRoleOverrideMap[$role->epGetObjectId()])) {
			return $this->userByRoleOverrideMap[$role->epGetObjectId()];
		}
		$ret = NULL;

		return $ret;
	}
}

?>